#include"Mapper.h"
#include"NROM.h"
#include"UxROM.h"

bool SwitchMapper(MAPPER**mapper,uint8_t mmc,CARTRIDGEBOARD *cart)
{
	bool t = false;
	switch (mmc)
	{
	case 0:    //NROM
		*mapper = malloc(sizeof(NROM));
		(*mapper)->cart = cart;
		if(NROMReset(*mapper))
			t=true;
		break;
	case 2:    //UXROM
		*mapper = malloc(sizeof(UXROM));
		(*mapper)->cart = cart;
		if (UXROMReset(*mapper))
			t = true;
		break;
	default:
		break;
	}
	return t;
}
void MapperFree(MAPPER*mapper)
{
	if (mapper)
		free(mapper);
}

